<?php
	$path_one = 'admin/admin_project';
	$path_two = 'admin/admin_project_manage';
	$filename = 'admin/admin_project_add';
	require_once("header.php");
	require_once("admin_comm.php");
	require_once $_site->get_handlepath('project');
	require_once $_site->get_handlepath('device');
	require_once $_site->get_handlepath('admin');
	$id= request('id',false,true);
	$result = project_fun_get_project_info($id);
	$admin_list = admin_fun_list(array('group'=>10,'state'=>1));//获取项目管理员列表
	
	$type=request('type',false,true,false,1);	
	
	//查看绑定详情
	$bid=request('bid',false,true,false,0);
	if($bid){
		$binfo=project_fun_get_bind_info($bid);
		$type=$binfo['type'];
	}
	
	//设备信息
	if($binfo['did'])$dinfo=device_fun_get_device_info($binfo['did']);	
?>
<script type="text/javascript" charset="utf-8">

	loader.file({
		plugin:['validform/main','dialog/main','my97/wdatepicker'],
		skincss:['list']
	});

	$(document).ready(function(){
		
		$("#choose_device").click(function(){
			dialog.iframe({
				title:'设备选择',
				is_resize:false,
				top:{
					is_show:true,
					btn_max:false,
					btn_min:false,
					btn_close:false,
					height:33,
					is_move:false
				},
				is_scroll:true,
				min_width:499,
				min_height:462,
				is_center:true,
				is_lock_back:true,
				content:'/admin/device_choice',
				name:'device_dialog'
			});
		})
		
		var form_obj=$("#form1").Validform({
		   tiptype: function(msg, o, cssctl){
			   if(!o.obj.is("form")){
				   var obj = o.obj.parent("td").find('tt');
				   cssctl(obj, o.type);
				   obj.text(msg);
			   }
		   },
		   ajaxPost:true,
		   callback:function (data){
				dialog.finish({
					content:data.msg,
					success:data.state,
					/*timeout:10000000,*/
					callback:function (){

						if(data.state){
							window.location.href=data.url?data.url:'/admin/admin_project_list'
						}

					}
				})
		   }
		})	
	})
	
	function choose_device(device){
		if(device.length != 1){
			return false;
		}
		$('#device_title').val(device.text()).focus().blur();
		$('input[name=device_id]').val(device.attr('device_id')).focus().blur();
	}

</script>
<style>
.dishes_top{width:100%}
.dishes_top a{text-decoration:none}
.dishes_top ul{float:left;width:100%;margin-top:10px}
.dishes_top ul li{display:inline-block;padding:0 5px}
.dishes_top ul li a{display:block;font-size:14px;height:35px;line-height:35px;width:140px;background-color:#eeeeee;color:#454545;font-size:14px;text-align:center}
.dishes_top ul li a:hover{background-color:#79473a;color:#ffffff}
.dishes_top ul li a.hover{background-color:#79473a;color:#ffffff}
.dishes_top .btn_submit{color:#FFFFFF; background:#289121;border:1px solid #c4c4c4;border-radius:2px;text-shadow:0 -1px 0 rgba(0, 0, 0, 0.25); border-color:#289121 #289121 #289121;padding:3px 15px;display:inline-block;cursor:pointer;font-size: 12px;}
.dishes_top .btn_submit:hover{background:#227E1C;}
</style>
</head>
<body>
	<div class="position_nav">你所在的当前位置：<?php echo $path_str;?> &gt; 设备绑定</div>
		<div class="main">
			<form action="/handle.php" method="post" id='form1'>
			<input type="hidden" name="h" value="project/bind_device">
			<input type="hidden" name="type" value="<?php echo $type;?>">
			<input type="hidden" name="bid" value="<?php echo $bid;?>">
			<div class="dishes_top">
			   <ul>			  			       				     		
				 <li><a<?php echo 1==$type?' class="hover"':'';?> href="?type=1&id=<?php echo $id;?>">工程车管理</a></li>				 				     						   				     		
				 <li><a<?php echo 2==$type?' class="hover"':'';?> href="?type=2&id=<?php echo $id;?>">油料管理</a></li>				 				     						   				     		
			   </ul>				  			   			  
			</div>			
			
			<table  cellpadding="0" cellspacing="1" border="0" class="table table_text">
				<tr>
					<td class="left">项目名称：</td>
					<td>
						<strong><?php echo $result['title'] ;?></strong>
						<input type="hidden" name="project_id" value="<?php echo $result['id'] ?>">
                        &nbsp;&nbsp;&nbsp;&nbsp;<a href="/admin/admin_project_device_list?type=<?php echo $type;?>&id=<?php echo $result['id'];?>" style="color: blue">查看已绑设备</a>
					</td>
				</tr>
				
				<?php if($binfo){  ?>
				<tr>
					<td class="left">绑定设备<font color="red">*</font>：</td>
					<td>
					    <b><?php echo $dinfo['no'];?></b>						
						<input type="hidden" name="device_id" value="<?php echo $dinfo['id'];?>">						
					</td>
				</tr>					
				<?php }else{ ?>
				<tr>
					<td class="left">绑定设备<font color="red">*</font>：</td>
					<td>
						<input type="text" class="w260" id="device_title" datatype="*" nullmsg="请绑定设备" value="<?php echo $dinfo['no'];?>" readonly="readonly">
						<input type="button" class="button1" value="选择设备" id="choose_device">
						<input type="hidden" name="device_id" datatype="*" value="<?php echo $dinfo['id'];?>" nullmsg="请绑定设备">
						<tt></tt>
					</td>
				</tr>		
				<?php } ?>
				
				<?php if(1==$type){  ?>
				
				<tr class="type_car">
					<td class="left">车牌号<font color="red">*</font>：</td>
					<td>
						<input type="text" name='car_number' class="w260" datatype="s1-30" nullmsg="请填写设备编号" value="<?php echo $binfo['car_number'];?>">
						<span class='comment'>在该项目下与手机设备号绑定的汽车标识号   <font>注意：请勿使用中文  </font></span>
						<tt></tt>
					</td>
				</tr>
				
				<tr class="type_car">
					<td class="left">车型<font color="red">*</font>：</td>
					<td>
						<input type="text" class='w260'  name='cartype' datatype='*' nullmsg='请填写型号' value="<?php echo $binfo['cartype'];?>"><span class='comment'></span><tt></tt>
					</td>
				</tr>				
				
				<tr class="type_car">
					<td class="left">产权人<font color="red">*</font>：</td>
					<td>
						<input type="text" class='w260'  name='link_man' datatype='*' nullmsg='请填写产权人' value="<?php echo $binfo['linkman'];?>"><span class='comment'></span><tt></tt>
					</td>
				</tr>				

				<tr class="type_car">
					<td class="left">电话：</td>
					<td>
						<input type="text" class='w260'  name='phone' value="<?php echo $binfo['phone'];?>"><span class='comment'></span><tt></tt>
					</td>
				</tr>					
				
				<?php }elseif(2==$type){ ?>
				
				<tr class="type_gas">
					<td class="left">人员工号：</td>
					<td>
						<input type="text" class='w260'  name='gaser' value="<?php echo $binfo['gaser'];?>"><span class='comment'></span>
						<span class='comment'>油料管理人员编号</span>
						<tt></tt>
					</td>
				</tr>							
				
				<?php } ?>
				
				<tr>
					<td></td>
					<td>
						<input class="button1" type="submit" value="添加">
					</td>
				</tr>

			</table>
			</form>
		</div>
	</div>
</body>
</html>




